Loading...
 

Gaussian elimination with a pivoting algorithm

Let us start Gaussian elimination again for our example, this time with a row swap (also called "pivoting").


\( \begin{bmatrix} {\color{blue}0.05} & 0.10833 & 0.00833 & 0 & 0 \\ {\color{red}0.10833} & 0.5 & 0.21666 & 0.00833 & 0 \\ {\color{blue}0.00833} & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ {\color{blue}0} & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ {\color{blue}0} & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix}1 \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix} \)
We start with the row pivoting operation. In the first column (marked in blue and red) we are looking for the highest value per module. It is an expression \( A_{2,1}=0.10833 \) (marked in red). So we swap the first line with the second one
\( \begin{bmatrix} {\color{red}0.10833} & 0.5 & 0.21666 & 0.00833 & 0 \\ {\color{blue}0.05} & 0.10833 & 0.00833 & 0 & 0 \\ {\color{blue}0.00833} & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ {\color{blue}0} & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ {\color{blue}0} & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix}1 \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix} \)
Now, we are performing the step of the "normal" Gaussian elimination algorithm. We scale the first row to get one on the diagonal
\( 1^{st}=1^{st}A_{1,1}=1^{st}\frac{1}{0.10833}=1^{st}9.231053 \)
\( \begin{bmatrix} 0.10833{\color{red}*9.23105} & 0.5{\color{red}*9.23105} & 0.21666{\color{red}*9.23105} & 0.00833{\color{red}*9.23105} & 0{\color{red}*9.23105} \\ 0.05 & 0.10833 & 0.00833 & 0 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 1{\color{red}*9.23105} \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} {\color{red}1} & {\color{red}4,61553} & {\color{red}2.00006} & {\color{red}0,07693} & {\color{red}0} \\ 0.05 & 0.10833 & 0.00833 & 0 & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix}{\color{red}9.2311} \\ 1 \\ 1 \\ 1 \\ 1 \end{bmatrix} \)
Then we subtract the first row from the second to get zero in position \( A_{2,1} \) \( 2^{nd}=2^{nd}-1^{st}A_{2,1}=2^{nd}-1^{st}0.05 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ {\color{red}0} & 0.10833{\color{red}-4.61553*0.05} & 0.00833{\color{red}-2*0.05} & 0{\color{red}-0.07693*0.05} & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix}9.23105 \\ 1{\color{red}-9.23105*0.05} \\ 1 \\ 1 \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ {\color{red}0} & {\color{red}-0.12244} & {\color{red}-0.09167} & {\color{red}-0,00385} & 0 \\ 0.00833 & 0.21666 & 0.55 & 0.21666 & 0.00833 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix}\begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ {\color{red}0.53844} \\ 1 \\ 1 \\ 1 \end{bmatrix} \)
We now subtract the first row from the third to get zero in position \( A_{3,1} \)
\( 3^{rd}=3^{rd}-1^{st}A_{3,1}=3^{rd}-1^{st}0.00833 \) \( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ {\color{red}0} & 0.21666{\color{red}-4.61552*0.00833} & 0.55{\color{red}-2*0.00833} & 0.21666 {\color{red}-0.07689*0.00833} & 0.00833{\color{red}-0} \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 0.53844 \\ 1{\color{red}-9.23105*0.00833} \\ 1 \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & -0.12244 & -0.09167 & -0,00385& 0 \\ {\color{red}0} & {\color{red}0.17821} & {\color{red}0.53334} & {\color{red}0.21603} & {\color{red}0.00833} \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 0.53844 \\ {\color{red}0.92310} \\ 1 \\ 1 \end{bmatrix} \)
We are now doing the row pivoting operation again.
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & {\color{blue}-0.12244} & -0.09167 & -0,00385 & 0 \\ 0 & {\color{red}0.17821} & 0.53334 & 0.21603 & 0.00833 \\ 0 & {\color{blue}0.00833} & 0.21666 & 0.5 & 0.10833 \\ 0 & {\color{blue}0} & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix}9.23105 \\ 0.53844 \\ 0.92310 \\ 1 \\ 1 \end{bmatrix} \)
In the second column from the diagonal down (marked in blue and red) we are looking for the highest value per module. It is an expression A(3,1)=0.17821 (marked in red) because \( |0.17821|>|-0.12244|=0.12244 \). So we swap the second row with the third one.
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & {\color{red}0.17821} & 0.53334 & 0.21603 & 0.00833 \\ 0 & {\color{blue}-0.12244} & -0.09167 & -0,00385 & 0 \\ 0 & {\color{blue}0.00833} & 0.21666 & 0.5 & 0.10833 \\ 0 & {\color{blue}0} & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 0.92310 \\ 0.53844 \\ 1 \\ 1 \end{bmatrix} \)
Now, we scale the new second row to get one on the diagonal \( 2^{nd}=2^{nd}\frac{1}{A_{2,2}}=2^{nd}\frac{1}{0.17821}=2^{nd}5.61135 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 0.17821{\color{red}*5.61135} & 0.53334{\color{red}*5.61135} & 0.21603{\color{red}*5.61135} & 0.00833{\color{red}*5.61135} \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 0.92310{\color{red}*5.61135} \\ 0.53844 \\ 1 \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & {\color{red}1} & {\color{red}2.99275} & {\color{red}1.21222} & {\color{red}0.046742} \\ 0 & -0.12244 & -0.09167 & -0,00385 & 0 \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ {\color{red}5.17983} \\ 0.53844 \\ 1 \\ 1 \end{bmatrix} \)
We now subtract the second row from the third scaled to get zero in position
\( A_{3,2}=-0.12244 \)
\( 3^{rd}=3^{rd}-2^{nd}A_{3,2}=3^{rd}-2^{nd}(-0.12244) \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & {\color{red}0} & -0.09167{\color{red}+2.99275*0.12244} & -0,00385{\color{red}+1.21222*0.12244} & 0{\color{red}+0.046742*0.12244} \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 0.53844{\color{red}+5.17983*0.12244} \\ 1 \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & {\color{red}0} & {\color{red}0.27479} & {\color{red}0.14459} & {\color{red}0.00573} \\ 0 & 0.00833 & 0.21666 & 0.5 & 0.10833 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.1800 \\ {\color{red}1.1727} \\ 1 \\ 1 \end{bmatrix} \)
Likewise, we subtract the second row from the fourth
\( 4^{th}=4^{th}-2^{nd}A_{(4,2}=4^{th}-2^{nd}0.00833 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27476 & 0.14457 & 0.005723 \\ 0 & {\color{red}0} & 0.21666{\color{red}-2.99275*0.00833} & 0.5{\color{red}-1.21210*0.00833} & 0.10833{\color{red}-0.046742*0.00833} \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 1.17265 \\ 1{\color{red}-5.17983*0.00833} \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27476 & 0.14457 & 0.005723 \\ 0 & {\color{red}0} & {\color{red}0.19173} & {\color{red}0.48990} & {\color{red}0.10794} \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix}9.23105 \\ 5.17999 \\ 1.17270 \\ {\color{red}0.95684} \\ 1 \end{bmatrix} \)
We are left with a 3 by 3 sub matrix in the lower right corner, for which we continue Gaussian elimination with row pivoting. We first look for the maximum (per module) value in the third column from the diagonal down (marked in red and blue). It is the value from the diagonal \( A_{3,3} \) marked in red, so we don't need to swap the rows. \( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & {\color{red}0.27476} & 0.14457 & 0.005723 \\ 0 & 0 & {\color{blue}0.19173} & 0.48990 & 0.10794 \\ 0 & 0 & {\color{blue}0.00833} & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 1.17265 \\ 0.95685 \\ 1 \end{bmatrix} \)
We now scale row three to get one on the diagonal
\( 3^{rd}=3^{rd}\frac{1}{A_{3,3}}=3^{rd}\frac{1}{0.27476}=3^{rd}3.63953 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 0.27476{\color{red}*3.63953} & 0.14457{\color{red}*3.63953} & 0.005723{\color{red}*3.63953} \\ 0 & 0 & 0.19173 & 0.48990 & 0.10794 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 1.17265{\color{red}*3.63953} \\ 0.95685 \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & {\color{red}1} & {\color{red}0.52617} & {\color{red}0.02082} \\ 0 & 0 & 0.19173 & 0.48990 & 0.10794 \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17999 \\ {\color{red}4.26763} \\ 0.95683 \\ 1 \end{bmatrix} \)
We will now use the third row to generate the zeros in the third column below the diagonal
\( 4^{th}=4^{th}-3^{rd}A_{4,3}=4^{th}-3^{rd}0.19173 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & {\color{red}0} & 0.48990{\color{red}-0.52618*0.19173} & 0.10794{\color{red}-0.02083*0.19173} \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.95685{\color{red}-4.26789*0.19173} \\ 1 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & {\color{red}0} & {\color{red}0.38901} & {\color{red}0.10395} \\ 0 & 0 & 0.00833 & 0.10833 & 0.05\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ {\color{red}0.13860} \\ 1 \end{bmatrix} \)
\( 5^{th}=5^{th}-3^{rd}A_{5,3}=5^{th}-3^{rd}0.00833 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 0.38901 & 0.10395 \\ 0 & 0 & {\color{red}0} & 0.10833{\color{red}-0.52618*0.00833} & 0.05{\color{red}-0.02082*0.00833}\\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.13860 \\ 1{\color{red}-4.26789*0.00833} \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 0.38901 & 0.10395 \\ 0 & 0 & 0 & {\color{red}0.10395} & {\color{red}0.04983}\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.13860 \\ {\color{red}0.96445} \end{bmatrix} \)
Then we scale the fourth row so that it has a one on the diagonal
\( 4^{th}=4^{th}\frac{1}{A_{4,4}}=4^{th}\frac{1}{0.38901}=4^{th}2.5706 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 0.38365{\color{red}*2.5706} & 0.10395{\color{red}*2.5706} \\ 0 & 0 & 0 & 0.10395 & 0.04982\\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ {\color{red}0.13860*2.5706} \\ 0.91110 \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & {\color{red}1} & {\color{red}0.26721} \\ 0 & 0 & 0 & 0.10395 & 0.04983 \\ \end{bmatrix} \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ {\color{red}0.35629} \\ 0.96444 \end{bmatrix} \)We will now use the fourth row to generate a zero in the fourth column below the diagonal \( 5^{th}=5^{th}-4^{rd}A_{5,4}=5^{th}-4^{rd}0.10395 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & {\color{red}0} & 0.04983{\color{red}-0.26721*0.10395} \\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.35629\\ 0.96444{\color{red}-0.35629*0.10395} \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & {\color{red}0} & {\color{red}0.022053} \\ \end{bmatrix} \nonumber\\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.35629 \\ {\color{red}0.92740} \end{bmatrix} \)
Finally, we scale the fifth row so that it has a one on the diagonal
\( 5^{th}=5^{th}\frac{1}{A_{5,5}}=5^{th}\frac{1}{0.022053}=5^{th}45.351 \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & {\color{red}0} & {\color{red}1} \\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.35629\\ 0.92740{\color{red}*45.351} \end{bmatrix} \)
\( \begin{bmatrix} 1 & 4.61553 & 2 & 0.07693 & 0 \\ 0 & 1 & 2.99287 & 1.21226 & 0.04676 \\ 0 & 0 & 1 & 0.52617 & 0.02082 \\ 0 & 0 & 0 & 1 & 0.26721 \\ 0 & 0 & 0 & {\color{red}0} & {\color{red}1} \\ \end{bmatrix} \\ \begin{bmatrix} u_{1} \\ u_{2} \\ u_{3} \\ u_{4} \\ u_{5} \\ \end{bmatrix} = \begin{bmatrix} 9.23105 \\ 5.17983 \\ 4.26789 \\ 0.35629\\ {\color{red}42.059} \end{bmatrix} \)
Writes \( 1u_1+4.61553u_2+2u_3+0.07693u_4=9.23105 \\ 1u_2+2.99287u_3+1.21226u_4+0.04676u_5=5.17983 \\ 1u_3+0.52617u_4+0.02082u_5=4.26789 \\ 1u_4+0.26721u_5=0.35629 \\ 1u_5=42.059 \)
And we solve from the last equation
\( u_5={\color{blue}42.059} \\ u_4=0.35629-0.26721u_5 =0.35629-0.26721*{\color{blue}42.059}={\color{red}-10.88229} \\ u_3=4.26789-0.52617u_4-0.02082u_5 =4.26789-0.52617{\color{red}-10.88229}-0.02082{\color{blue}42.059}={\color{green}9.11815} \\ u_2=5.17983-2.99287u_3-1.21226u_4-0.04676u_5= \\ =5.17983-2.99287{\color{green}9.11815}-1.21226{\color{red}-10.88229}-0.04676{\color{blue}42.059} = {\color{cyan}-10,88412} \\ u_1=9.23105-4.61553u_2-2u_3-0.07693u_4 = 42.0679 \)
This time our solution is correct.

The Gaussian elimination algorithm should be enriched with row pivoting.


1 for irow=1,N //loop by line
2 Find the largest value in a column A(row:N,irow)
3 Mark the row with the highest irowmax value
4 Swap rows irow, irowmax
5 for icol=irow+1,N // row scaling
6 A(irow,icol)=A(irow,icol)/A(irow,irow)
7 end loop
8 b(irow)=b(irow)/A(irow,irow)
9 A(irow,irow)=1.0
10 for irow2=irow+1,N //line subtraction
11 for icol=irow2+1,N
12 A(irow2,icol) = A(irow2,icol) - A(irow2,irow) * A(irow,icol)
13 end loop
14 b(irow2)=b(irow2)-A(irow2,irow)*b(irow2)
15 A(irow2,irow)=0
16 end loop
17end loop


Ostatnio zmieniona Sobota 09 z Lipiec, 2022 11:18:18 UTC Autor: Maciej Paszynski
Zaloguj się/Zarejestruj w OPEN AGH e-podręczniki
Czy masz już hasło?

Hasło powinno mieć przynajmniej 8 znaków, litery i cyfry oraz co najmniej jeden znak specjalny.

Przypominanie hasła

Wprowadź swój adres e-mail, abyśmy mogli przesłać Ci informację o nowym haśle.
Dziękujemy za rejestrację!
Na wskazany w rejestracji adres został wysłany e-mail z linkiem aktywacyjnym.
Wprowadzone hasło/login są błędne.